import { Operation } from './operation'
import type Editor from './../editor'
import { InsertTextOperation } from './insert_text_operation'

export class RemoveTextOperation extends Operation {
    private _startIndex:number;
    private _endIndex:number;
    private _text:string;
    constructor (text : string,startIndex:number, endIndex:number) {
        super()
        this._startIndex = startIndex
        this._endIndex = endIndex
        this._text = text
    }
    apply (editor:Editor) : void{
        editor.getTextModel().remove(this._startIndex, this._endIndex);
    }

    reverse():Operation {
        return new InsertTextOperation(this._text, this._startIndex > this._endIndex ? this._endIndex: this._startIndex)
    }
}
export default RemoveTextOperation